import hilog from '@ohos.hilog';

const TAG = 'Winslei_Default'

const LOG_DOMAIN = 0x1027

export default class WinsleiLogManager {

    public static abilityName: string = ''

    // console.log
    public static log(tag: string, msg: string) {
        console.log(`${TAG} tag: ${tag} --> ${msg}`)
    }

    // hilog
    public static hilogD(msg: string) {
        if (hilog.isLoggable(LOG_DOMAIN, TAG, hilog.LogLevel.DEBUG)) {
            hilog.debug(LOG_DOMAIN, TAG, msg)
        }
    }

    public static hilogI(msg: string) {
        if (hilog.isLoggable(LOG_DOMAIN, TAG, hilog.LogLevel.INFO)) {
            hilog.info(LOG_DOMAIN, TAG, msg)
        }
    }

    public static hilogIWithTag(tag: string, msg: string) {
        if (hilog.isLoggable(LOG_DOMAIN, TAG, hilog.LogLevel.INFO)) {
            hilog.info(LOG_DOMAIN, TAG, `tag: ` + (this.abilityName.length > 0 ? `(${this.abilityName})` : '') + ` ${tag} --> ${msg}`)
        }
    }
}